package com.honey.mybatis.generator.dao;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.compilation.java.Field;
import com.honey.compilation.java.Method;
import com.honey.core.compiler.CompilationException;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.mybatis.generator.AbstractProduceJavaCompilation;
import com.honey.mybatis.generator.MybatisPlugin;
import com.honey.mybatis.generator.dao.method.GetNameSpaceMethod;

public class ProduceDaoImplements extends AbstractProduceJavaCompilation {
	
	public ProduceDaoImplements(MybatisPlugin mybatisPlugin,
			IntrospectSchema introspectSchema,
			IntrospectSchemaColumn introspectSchemaColumn) {
		super(mybatisPlugin, introspectSchema, introspectSchemaColumn);
	}

	private AbstractJavaCompilation abstractJavaCompilation ;
	
	@Override
	public AbstractJavaCompilation produceCompilation() throws CompilationException {
		abstractJavaCompilation = new DaoImplements(mybatisPlugin, introspectSchema, introspectSchemaColumn).createJavaCompilation(); 
		return abstractJavaCompilation ;
	}

	@Override
	public Field[] produceFields() throws CompilationException {
		return new Field[]{
			/*
			new CountField().createField(),
			new SelectAllField().createField(),
			new SelectByPrimaryKeyField().createField(),
			new SelectByDynamicField().createField(),
			new DeleteByPrimaryKeyField().createField(),
			new DeleteByDynamicField().createField(),
			new InsertField().createField(),
			new InsertSelectiveField().createField(),
			new UpdateByPrimaryKeyField().createField(),
			new UpdateByPrimaryKeySelectiveField().createField(),
			new UpdateByDynamicSelectiveField().createField(),
			new UpdateByDynamicField().createField(),
			new ExistsField().createField(),
			*/
		};
	}
	/* (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractProduceJavaCompilation#produceImportClass()
	 */
	@Override
	public FullyQualifiedJavaType[] produceImportClass()
			throws CompilationException {
		
		return null;
	}

	@Override
	public Method[] produceMethods() throws CompilationException {
		/*
		List<Method> answer = new ArrayList<Method>();
		
		answer.add( new CountMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new CountMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
		
		answer.add( new ExistsMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new ExistsMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
	
		
		answer.add( new SelectByPrimaryKeyMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new SelectByPrimaryKeyMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
	
		answer.add( new SelectAllMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new SelectAllMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,false,true).createMethod() );
		answer.add( new SelectAllMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true,false).createMethod() );
		answer.add( new SelectAllMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true,true).createMethod() );
		
		answer.add( new SelectByDynamicMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new SelectByDynamicMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,false,true).createMethod() );
		answer.add( new SelectByDynamicMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true,false).createMethod() );
		answer.add( new SelectByDynamicMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true,true).createMethod() );
		
		answer.add( new SelectOneByDynamicMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new SelectOneByDynamicMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
		
		answer.add( new DeleteByDynamicMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new DeleteByDynamicMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
		
		answer.add( new DeleteByPrimaryKeyMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new DeleteByPrimaryKeyMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );

		answer.add( new InsertMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new InsertMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
		
		answer.add( new InsertSelectiveMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new InsertSelectiveMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
		
		answer.add( new SaveMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new SaveMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
		
		answer.add( new UpdateByPrimaryKeyMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new UpdateByPrimaryKeyMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
		
		answer.add( new UpdateByPrimaryKeySelectiveMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new UpdateByPrimaryKeySelectiveMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
		
		answer.add( new UpdateByDynamicSelectiveMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new UpdateByDynamicSelectiveMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
		
		answer.add( new UpdateByDynamicMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod() );
		answer.add( new UpdateByDynamicMethod(abstractJavaCompilation, mybatisPlugin, introspectSchema, introspectSchemaColumn,true).createMethod() );
		
		
		return answer.toArray( new Method [answer.size()] );
		*/
		return new Method[]{ 
				new GetNameSpaceMethod().createMethod() 
		};
		
	}

	public AbstractJavaCompilation getAbstractJavaCompilation() {
		return abstractJavaCompilation;
	}
	
}
